<?php
/**
 * 
 * @author yuxun
 *
 */

class ModMonitordb {
	
	public static function getServerInfoListBy($type){
		$year_month = date('Ym');
		$table = 'monitor_server_'.$year_month;
		
		$sql = "SELECT t.*  FROM (SELECT * FROM ".$table." ORDER BY ctime DESC) t  GROUP BY t.ip ";
	
		$dbName = 'monitordb';
	
		$dbLink = new PubDbLink('dbmonitordb', $dbName);
	
		if(!$dbLink){
			return array();
		}
	
		$list = $dbLink->query($sql);
	
		return $list;
	}

	public static function getServerInfoList($type){
		$year_month = date('Ym');
		$table = 'monitor_server_'.$year_month;
		$sql = "select * from ".$table.' order by ctime desc limit 1';

		$dbName = 'monitordb';
	
		$dbLink = new PubDbLink('dbmonitordb', $dbName);
	
		if(!$dbLink){
			return array();
		}
	
		$list = $dbLink->query($sql);
	
		return $list;
	}
	
	public static function online($run_bash){
		$year_month = date('Ym');
		//$table = 'monitor_online_desc';
		$table = 'monitor_online_'.$year_month;
		//$run_bash = '201811051150';
		//echo $run_bash;
		$sql = "select * from ".$table." where id = '".$run_bash."'";
		$dbName = 'monitordb';
		$dbLink = new PubDbLink('dbmonitordb', $dbName);
		
		if(!$dbLink){
			return array();
		}
		
		$list = $dbLink->query($sql);

		return $list;
	}
    
    
} 